// 在使用组件时，
// 默认会在 index.js 中寻找 export 的对象，
// 如果你的组件比较复杂，可以分为多个文件，
// 最后在 index.js 中统一 export


import React, {PureComponent} from 'react';
import 'antd/dist/antd.css';
// import './index.less';
import {Form, TreeSelect,} from 'antd';


@Form.create()
class DirTreeSelect extends PureComponent {
  state = {
    value: undefined,
  }

  onChange = (value) => {
    const {onItemSelected} = this.props;
    console.log(value);
    this.setState({value});
    onItemSelected(value);
  }

  render() {
    const {dirTreeList, onItemSelected} = this.props;
    return (
      <TreeSelect
        style={{width: 300}}
        value={this.state.value}
        dropdownStyle={{maxHeight: 400, overflow: 'auto'}}
        treeData={dirTreeList}
        placeholder="请选择"
        treeDefaultExpandAll
        onChange={this.onChange}
      />
    );
  }
}

export default DirTreeSelect;
